﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AVI;

namespace UseCamera
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }
        Video v = null;



        #region 打开视频设备按钮的事件
        /// <summary>
        /// 打开视频设备按钮的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_openCamera_Click(object sender, EventArgs e)
        {
            v = new Video(this.pnlCamera.Handle, this.pnlCamera.Width, this.pnlCamera.Height);
            //v = new Video(this.Handle, this.pnlCamera.Width, this.pnlCamera.Height);
            v.StartWebCam();


        }
        #endregion

        private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            //v.CloseWebcam(0);
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            //v.setCaptureFormat();
            //v.setVideoCompression();
            v.StarKinescope("a.avi");

            //测试流
            //v.ToStream("a.avi");
            //v.grabImage("b.jpg");
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            v.StopKinescope();
        }
    }
}
